package com.zm.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zm.pojo.AppCategory;
import com.zm.pojo.DataDictionary;
import com.zm.service.AppCategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by CYJ on 2018/9/17.
 */
@RequestMapping("/category")
//@Controller
//@ResponseBody
@RestController
public class AppCategoryController {
    @Resource
    private AppCategoryService appCategoryService;

    /**
     * 通过ajax查询3级分类
     * @param
     */
    @RequestMapping("/queryCategory")
    public Object queryCategory(String level) {

        if (level.equals("level1")) {
            List<AppCategory> levle1 = appCategoryService.queryByCategoryLevel1();
            return JSONObject.toJSONString(levle1);
        } else if (level.equals("level2")) {
            List<AppCategory> levle2 = appCategoryService.queryByCategoryLevel2();
            return  JSONObject.toJSONString(levle2);
        } else if (level.equals("level3")) {
            List<AppCategory> levle3 = appCategoryService.queryByCategoryLevel3();
            return JSONObject.toJSONString(levle3);
        }
        return null;
    }

}
